<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from "./chart.vue";
export default {
  data() {
    return {
      cdata: {
        category: ["自行申报", "扣缴单位集中申报", "委托代理申报"],
        legend: ["非豁免补税", "豁免补税", "申报退税", "不补不退"],
        barData: {
          fhmbs: [712134, 109320, 111130],
          hmbs: [122134, 322290, 233130],
          sbts: [121190, 123330, 11110],
          bbbt: [81214, 23109, 1231],
          tj: [],
        },
      },
    };
  },
  components: {
    Chart,
  },
  mounted() {
    this.setData();
  },
  methods: {
    // 根据自己的业务情况修改
    setData() {
      const maxDataLen = 4;
      const { fhmbs, hmbs, sbts, bbbt } = this.cdata.barData;
      for (let i = 0; i < maxDataLen - 1; i++) {
        const totalCount = fhmbs[i] + hmbs[i] + sbts[i] + bbbt[i];
        this.cdata.barData.tj.push(totalCount);
      }
    },
  },
};
</script>

<style lang="scss" scoped></style>
